package com.czlis.boe;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.csb.sdk.HttpCaller;
import com.alibaba.fastjson.JSON;

public class MesBadInfoClient {
	public static void main(String args[]){
		Map<String,String> map1 = new HashMap<String, String>();
		
		map1.put("startDate", "2018-12-14");
		map1.put("endDate", "2018-12-14");
		map1.put("startTime","08:00:00");
		map1.put("endTime", "20:00:00");
		map1.put("shipper", "B3");
		map1.put("oemMill", "1003653");
		map1.put("proModel", "BH156A");
		map1.put("fgcode", "NT156WHM-N42-8D36");
		map1.put("cellNo", "");
		map1.put("orderNo", "B8P156WH5TP02-P");
		map1.put("badSite", "1008");
		map1.put("gradeOne", "N");
		map1.put("gradeTwo", "G");
		map1.put("defectCode", "POL脏污");
		map1.put("badNum", "2");
		map1.put("unit", "Pcs");
		map1.put("type", "制程不良");
		map1.put("happenDate", "2018-12-13 00:00:00");
		map1.put("workstop", "1");
		map1.put("proLine", "1");
		map1.put("incommingModel", "7");
		
		List<Map<String,String>> list = new ArrayList<Map<String,String>>();
		
		list.add(map1);
		
		Map<String,Object> item = new HashMap<String, Object>();
		item.put("item", list);
		Map<String,String> map3 = new HashMap<String, String>();
		map3.put("mesBadinfos", JSON.toJSONString(item));
		
		System.out.println(JSON.toJSONString(item));
		System.out.println(JSON.toJSON(map3));
		
		//测试外网
		String requestURL = "https://210.12.224.195:443/test";
		//内网
		//String requestURL = "https://10.80.25.151:8086/test";
		String API_NAME = "MESBADINFODATA";
		String ak = "82f16f644ac34f6e968764322f4bd7b0";
		String sk = "jgAgaxG8/O9zmc+yx626aJDZsW8=";
		//生产外网
//		String requestURL = "https://api-csb-broker.boe.com.cn:443/test";
//		String API_NAME = "MESBADINFODATA";
//		String ak ="257a453ef52e4498979a2c317c79622f";
//		String sk ="bp9zFdmDI18mBKbYlM8bDgPCvO4=";
		try {
			for(int i=0;i<1;i++){
//				 String result = doGet();https://api-csb-broker.boe.com.cn:443/test
					String result = HttpCaller.doPost(requestURL,API_NAME, "1.0.0"  , map3, ak, sk);
//					  String result = doGet(requestURL, API_NAME, "1.0.0" ,map1, ak, sk);
					  if (result != null) {
						 System.out.println("******************************");
						 String result2 = new String(result.getBytes("GB2312"), "ISO-8859-1");
						 //int a = result.getBytes("GB2312").length;
						 //System.out.println(a);
						 System.out.println(result2); 
						 
					  }
			}
			} catch (Exception ie) {
				ie.printStackTrace();
		}
	}
}
